﻿using Gdmec.Cache;
using Gdmec.Config;
using System;
using System.Collections;
using System.IO;
using UnityEngine;

namespace Gdmec.Load
{
    public class LoadManager : Loader
    {
        public static LoadManager Instance { get; private set; }
        protected override void Awake()
        {
            Instance = this;
        }

        private void OnDestroy()
        {
            Instance = null;
        }

        public static void SetCache(CacheManager cache)
        {
            Instance.Cache = cache;
        }

        public static void Load(string name, string[] paths, Action onFinish)
        {
            var task = Instance.GetLoadTask();
            task.name = name;
            task.onFinish += onFinish;
            task.paths.AddRange(paths);
            Instance.DoLoadTask(task);
        }
    }
}
